package com.dlc.hardwareprotocol.serialport.command.recv;

import java.util.Arrays;

/**
 * 控制板的工作状态BA
 */
public class RecvBA extends RecvBase {
    private int flowNo;
    private int shipmentState;
    private int currentStep;
    private int errCode;
    private int th1ShipmentResult;
    private int th2ShipmentResult;
    private int th3ShipmentResult;
    private int th4ShipmentResult;
    private int th5ShipmentResult;
    private int outState;
    private int inState;
    private int auxiliaryInPulseCount1;
    private int auxiliaryInPulseCount2;
    private String temperature;
    private int deviceType;//柜子类型	0x00：弹簧履带柜  0x01：格子柜
    private byte[] boxSwitchStates;//格子柜开关状态 第0字节BIT0为第1行第9列状态，BIT1为第1行第10列状态 第1字节BIT0为第1行第1列状态，BIT1为第1行第2列状态 第3字节BIT0为第2行第9列状态，BIT1为第2行第10列状态 第4字节BIT0为第2行第1列状态，BIT1为第2行第2列状态 第19字节BIT0为第10行第9列状态，BIT1为第10行第10列状态 第20字节BIT0为第10行第1列状态，BIT1为第10行第2列状态
    private int place;//保留

    public RecvBA(byte[] mAllPack, byte[] data, int cmd) {
        super(mAllPack, data, cmd);
        int readIndex = 0;
        this.flowNo = data[readIndex++] & 0xFF;
        this.shipmentState = data[readIndex++] & 0xFF;
        this.currentStep = data[readIndex++] & 0xFF;
        this.errCode = data[readIndex++] & 0xFF;
        this.th1ShipmentResult = data[readIndex++] & 0xFF;
        this.th2ShipmentResult = data[readIndex++] & 0xFF;
        this.th3ShipmentResult = data[readIndex++] & 0xFF;
        this.th4ShipmentResult = data[readIndex++] & 0xFF;
        this.th5ShipmentResult = data[readIndex++] & 0xFF;
        this.outState = data[readIndex++] & 0xFF;
        this.inState = data[readIndex++] & 0xFF;
        this.auxiliaryInPulseCount1 = data[readIndex++] & 0xFF;
        this.auxiliaryInPulseCount2 = data[readIndex++] & 0xFF;
        byte[] temperatureBytes = new byte[5];
        System.arraycopy(data, readIndex, temperatureBytes, 0, temperatureBytes.length);
        readIndex += temperatureBytes.length;
        this.temperature = new String(temperatureBytes);
        this.deviceType = data[readIndex++] & 0xFF;
        byte[] boxSwitchStatesBytes = new byte[20];
        System.arraycopy(data, readIndex, boxSwitchStatesBytes, 0, boxSwitchStatesBytes.length);
        readIndex += boxSwitchStatesBytes.length;
        this.boxSwitchStates = boxSwitchStatesBytes;
        this.place = data[readIndex++] & 0xFF;
    }

    public int getFlowNo() {
        return flowNo;
    }

    public int getShipmentState() {
        return shipmentState;
    }

    public int getCurrentStep() {
        return currentStep;
    }

    public int getErrCode() {
        return errCode;
    }

    public int getTh1ShipmentResult() {
        return th1ShipmentResult;
    }

    public int getTh2ShipmentResult() {
        return th2ShipmentResult;
    }

    public int getTh3ShipmentResult() {
        return th3ShipmentResult;
    }

    public int getTh4ShipmentResult() {
        return th4ShipmentResult;
    }

    public int getTh5ShipmentResult() {
        return th5ShipmentResult;
    }

    public int getOutState() {
        return outState;
    }

    public int getInState() {
        return inState;
    }

    public int getAuxiliaryInPulseCount1() {
        return auxiliaryInPulseCount1;
    }

    public int getAuxiliaryInPulseCount2() {
        return auxiliaryInPulseCount2;
    }

    public String getTemperature() {
        return temperature;
    }

    public int getDeviceType() {
        return deviceType;
    }

    public byte[] getBoxSwitchStates() {
        return boxSwitchStates;
    }

    @Override
    public String toString() {
        return "RecvBA{" +
                "flowNo=" + flowNo +
                ", shipmentState=" + shipmentState +
                ", currentStep=" + currentStep +
                ", errCode=" + errCode +
                ", th1ShipmentResult=" + th1ShipmentResult +
                ", th2ShipmentResult=" + th2ShipmentResult +
                ", th3ShipmentResult=" + th3ShipmentResult +
                ", th4ShipmentResult=" + th4ShipmentResult +
                ", th5ShipmentResult=" + th5ShipmentResult +
                ", outState=" + outState +
                ", inState=" + inState +
                ", auxiliaryInPulseCount1=" + auxiliaryInPulseCount1 +
                ", auxiliaryInPulseCount2=" + auxiliaryInPulseCount2 +
                ", temperature='" + temperature + '\'' +
                ", deviceType=" + deviceType +
                ", boxSwitchStates=" + Arrays.toString(boxSwitchStates) +
                ", place=" + place +
                '}';
    }
}
